package br.com.gp.controller;

import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import br.com.gp.fabrica.Atendente;

public abstract class ControllerPadrao {

	@SuppressWarnings("rawtypes")
	protected transient Map sessionScope;

	public static final String CURRENT_PAGE=null;
	
	public Atendente atendente;

	protected void setInfoMessage(String summary) {
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, summary, null));
	}

	protected void setErroMessage(String summary) {
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, null));
	}

	protected void setWarMessage(String summary) {
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, summary, null));
	}

	@SuppressWarnings({ "rawtypes", "deprecation" })
	public Map getSessionScope() {
		FacesContext context = FacesContext.getCurrentInstance();
		if (context != null) {
			sessionScope = (Map) context.getApplication().createValueBinding(
					"#{sessionScope}").getValue(context);
		}
		return sessionScope;
	}

	public Atendente getAtendente() {
		if(atendente==null){
			atendente = new Atendente();
		}
		return atendente;
	}

	public void setAtendente(Atendente atendente) {
		this.atendente = atendente;
	}

}